package com.example.team.controller;

import com.example.team.entity.Test;
import com.example.team.service.ITestService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 编写者：
 * 时间：
 */
@RestController
@Api(tags = "测试")
public class TestController {
    @Autowired
    private ITestService userService;

    @ApiOperation(value = "添加用户",
            notes = "成功返回1")
    @RequestMapping("/insertUser")
    public int insertUser(Test test){
        return userService.insertUser(test);
    }

    @ApiOperation(value = "删除用户",
            notes = "成功返回1")
    @RequestMapping("/deleteUser")
    public int deleteUser(int id){
        Test test =new Test();
        test.setId(id);
        return userService.deleteUser(test);
    }

    @ApiOperation(value = "修改用户信息",
            notes = "成功返回1")
    @RequestMapping("/updateUser")
    public int updateUser(Test test){
        return userService.updateUser(test);
    }

    @ApiOperation(value = "查询所有用户信息",
            notes = "成功返回Json")
    @RequestMapping("/getAllUser")
    public List<Test> getAllUser(String name){
        Test test =new Test();
        test.setName(name);
        return userService.getAllUser(test);
    }

    @ApiOperation(value = "查询用户信息",
            notes = "成功返回Json")
    @RequestMapping("/getUser")
    public Test getUser(String name){
        Test test =new Test();
        test.setName(name);
        return userService.getUser(test);
    }
}
